﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：李刚 
    //
    // 文件名：WebHint.cs
    // 文件功能描述：页面操作信息处理
    // 创建标识：李刚 2009-03-23
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace HZ.DrugTrade.Web
{
    public class WebHint
    {
        /// <summary>
        /// 页面错误提示信息
        /// </summary>
        /// <param name="ErrMsg">错误信息</param>
        /// <param name="Url">返回管理员地址  默认可以填写:""或"0"</param>
        /// 更新时间2007-3-7
        static public void ShowError(string ErrMsg, string ReturnUrl)
        {
            PageRender(ErrMsg, ReturnUrl, false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="StrUrl"></param>
        /// <returns></returns>
        static private string UserUrl(string StrUrl)
        {
            if (StrUrl.Trim() != string.Empty && StrUrl.Trim().Length > 5)
            {
                StrUrl = "<a href=\"" + StrUrl + "\"><font color=\"red\">返回</font></a>";
            }
            return StrUrl;
        }

        /// <summary>
        /// 页面操作成功提示信息
        /// </summary>
        /// <param name="RightMsg">操作成功信息</param>
        /// <param name="Url">返回管理员地址</param>
        static public void ShowInfo(string RightMsg, string ReturnUrl)
        {
            PageRender(RightMsg, ReturnUrl, true);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="Url">返回URl</param>
        /// <param name="Succeed"></param>
        static internal void PageRender(string Msg, string ReturnUrl, bool Succeed)
        {
            string strTitle = "操作结果";
            string strClass = "msg info";

            if (!Succeed)
            {
                strClass = "msg warning";
            }
            if (ReturnUrl.Trim() == "")
            {
                //ReturnUrl = "JavaScript:{history.go(-1);};";
                ReturnUrl = HttpContext.Current.Request.RawUrl;
            }
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.Write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r<head>\r");
            System.Web.HttpContext.Current.Response.Write("<title>" + strTitle + " 内蒙古自治区药械集中采购平台。</title>\r");
            System.Web.HttpContext.Current.Response.Write("<link href=\"" + VirtualPathUtility.ToAbsolute("~/")+ "lib/style/global.css\" rel=\"stylesheet\" type=\"text/css\" />\r");
            System.Web.HttpContext.Current.Response.Write("<script src=\"" + VirtualPathUtility.ToAbsolute("~/") + "lib/scripts/global.js\" language=\"javascript\" type=\"text/javascript\"></script>\r");
            System.Web.HttpContext.Current.Response.Write("\r</head>\r");

            System.Web.HttpContext.Current.Response.Write("<body style=\"margin-top:50px;\">\r");

            System.Web.HttpContext.Current.Response.Write(" <br><table class=\"MessageBox\" width=\"300\"  align=\"center\">");
            System.Web.HttpContext.Current.Response.Write("<tr><td class=\"" + strClass + "\">");
            System.Web.HttpContext.Current.Response.Write("<div class=\"content\" style=\"font-size:12pt\"><pre>" + Msg + "</pre></div>");
            System.Web.HttpContext.Current.Response.Write("</td></tr></table><br>");
            System.Web.HttpContext.Current.Response.Write("<center><input type=\"button\" class=\"btn\" value=\"返回\" onclick=\"window.location='" + ReturnUrl + "';\"></center>");
            System.Web.HttpContext.Current.Response.Write("</body>\r</html>\r");
            System.Web.HttpContext.Current.Response.End();
        }
    }
}
